﻿//<![CDATA[

function trim(s) {
    return rtrim(ltrim(s));
}

function ltrim(s) {
    var l = 0;
    while (l < s.length && s[l] == ' ')
    { l++; }
    return s.substring(l, s.length);
}

function rtrim(s) {
    var r = s.length - 1;
    while (r > 0 && s[r] == ' ')
    { r -= 1; }
    return s.substring(0, r + 1);
}



function RemoveTextSpaces(objInput) {
    objInput.value = removeSpaces(objInput.value);
}

function removeSpaces(inputstring) {
    return inputstring.split(' ').join('');
}

function SubmitOnClientClick(aSubmitButton, valGroup) {
    LoadValidationErrorCss();
    if (Page_ClientValidate(valGroup)) {
        ShowNormalProcessing(aSubmitButton);
    }
}

function restrictToNumbers(e) {
    if ([e.keyCode || e.which] == 8 || [e.keyCode || e.which] == 37 || [e.keyCode || e.which] == 9 || [e.keyCode || e.which] == 39) //this is to allow backspace
        return true;

    if ([e.keyCode || e.which] < 48 || [e.keyCode || e.which] > 57)
        e.preventDefault ? e.preventDefault() : e.returnValue = false;
}

function restrictNoInputs(e) {
    e.preventDefault ? e.preventDefault() : e.returnValue = false;
}

function restrictNoSpecialChars(e) {
    //! = 33
    //@ = 64
    //# = 35
    //$ = 36
    //% = 37
    //* = 42
    //^ = 94
    if ([e.keyCode || e.which] == 8 || [e.keyCode || e.which] == 37 || [e.keyCode || e.which] == 39) //this is to allow backspace
        return true;

    if ([e.keyCode || e.which] == 33 || [e.keyCode || e.which] == 64 || [e.keyCode || e.which] == 35 || [e.keyCode || e.which] == 36 || [e.keyCode || e.which] == 37 || [e.keyCode || e.which] == 42 || [e.keyCode || e.which] == 94)
        e.preventDefault ? e.preventDefault() : e.returnValue = false;
}

function restrictToEmailChars(e) {
    //! = 33
    //# = 35
    //$ = 36
    //% = 37
    //& = 38
    //( = 40
    //) = 41
    //* = 42
    //^ = 94
    //backspace = 8
    //left = 37
    //right = 39
    if ([e.keyCode || e.which] == 8 || [e.keyCode || e.which] == 37 || [e.keyCode || e.which] == 39) //this is to allow backspace
        return true;

    if ([e.keyCode || e.which] == 33 || [e.keyCode || e.which] == 35 || [e.keyCode || e.which] == 36 || [e.keyCode || e.which] == 37 || [e.keyCode || e.which] == 38 || [e.keyCode || e.which] == 40 || [e.keyCode || e.which] == 41 || [e.keyCode || e.which] == 42 || [e.keyCode || e.which] == 94)
        e.preventDefault ? e.preventDefault() : e.returnValue = false;
}

function isDateValid(year, month, day) {
    var source_date = new Date(year, month, day);

    if (year != source_date.getFullYear()) {
        //alert('Year is not valid!' + year + ' : ' + source_date.getFullYear());							
        return false;
    }

    if (month != source_date.getMonth()) {
        // alert('Month is not valid!' + month + ' : ' + source_date.getMonth());		
        return false;
    }

    if (day != source_date.getDate()) {
        //  alert('Day is not valid!' + day + ' : ' + source_date.getDate());	
        return false;
    }

    return true;
}

function CheckFloatNumberValueClientSide(sender, args) {
    var _valCtrl = document.getElementById(sender.id.toString());
    var _txtCtrl = document.getElementById(_valCtrl.controltovalidate);
    //alert(parseFloat(_txtCtrl.value));
    if (parseFloat(_txtCtrl.value) > 0) {
        args.IsValid = true;
        //alert("is valid");
        _txtCtrl.className = _txtCtrl.className.replace(new RegExp("\\b" + "validationError" + "\\b", "i"), "").replace(/^\s+|\s(?=\s+)|\s+$/m, "");
    }
    else {
        //alert("Please enter valid price amount!");

        _txtCtrl.className += (_txtCtrl.className.length != 0 ? " " : "") + "validationError";

        //alert(_txtCtrl.id + " " + _txtCtrl.className);
        args.IsValid = false;
    }
    //alert(args.isvalid);
    //return args.isvalid;
}

function CheckNumberValueClientSide(sender, args) {
    var _valCtrl = document.getElementById(sender.id.toString());
    var _txtCtrl = document.getElementById(_valCtrl.controltovalidate);
    //alert(parseInt(_txtCtrl.value));
    if (parseInt(_txtCtrl.value) > 0) {
        args.IsValid = true;
        //alert("is valid");
        _txtCtrl.className = _txtCtrl.className.replace(new RegExp("\\b" + "validationError" + "\\b", "i"), "").replace(/^\s+|\s(?=\s+)|\s+$/m, "");
    }
    else {
        //alert("Please enter valid price amount!");

        _txtCtrl.className += (_txtCtrl.className.length != 0 ? " " : "") + "validationError";

        //alert(_txtCtrl.id + " " + _txtCtrl.className);
        args.IsValid = false;
    }
    //alert(args.isvalid);
    //return args.isvalid;
}

//#################################//
//usrPhone
function PhoneNoLengthClientValidate(source, arguments) {

    if (arguments.Value.length != 0 && arguments.Value.length < 5) {
        arguments.IsValid = false;
    } else {
        arguments.IsValid = true;
    }
}

function CheckPhoneNoClientValidate(source, arguments) {
    arguments.Value = trim(arguments.Value);
    arguments.Value = removeSpaces(arguments.Value);
    //alert(arguments.Value);
    //document.getElementById(source.id).Value = arguments.Value;
    //alert(source.id);
    var cval = parseInt(arguments.Value);
    if (isNaN(cval)) {
        arguments.IsValid = false;
        alert('hello isNaN');
    }
    else if (cval <= 0) {
        alert('hello cval <= 0');
        arguments.IsValid = false;
    }
    else {
        var cstrVal = "" + cval + "";
        if (cstrVal.length < 5) {
            arguments.IsValid = false;
        }
        //else if (cstrVal.charAt(0) == "0") {
        //    arguments.IsValid = false;
        //}
        else {
            arguments.IsValid = true;
        }
    }
}
//END usrPhone
//#################################//

//################################//
//LOADING PROGRESS//

var num = 1;
var tim;
var count = 3;
var submitTime;
var pageTime;

window.onbeforeunload = ShowPageLoadingProgress;

function HideLoading() {
    if (num == 5) {
        document.getElementById('divLoading').style.display = "none";
        document.getElementById('contentBody').style.display = "";
        window.clearTimeout(tim);
    }
    else {
        count--;
        document.getElementById('divLoadingMessage').innerHTML = " Please wait ..."; //" + count.toString() + " seconds...";
        tim = window.setTimeout("HideLoading()", 1000);

    }
    num++;
}

function IncreaseProgress(valPercent) {
    document.getElementById('divPgrPercent').innerHTML = valPercent.toString() + "%";
    document.getElementById('divPgrBar').style.width = valPercent.toString() + "%";
    //document.getElementById('pgrBar').style.width= valPercent.toString() + "%";
}



function ShowSubmitLoading() {
    /*document.getElementById('divPageLoading').style.display = "none";
    document.getElementById('divSubmitLoading').style.display = "";
    window.clearTimeout(submitTime);
    submitTime =  window.setTimeout("ChangeSubmitMessage()", 5000);*/
}

function ChangeSubmitMessage() {
    document.getElementById('divLoadingMessage').innerHTML = "Still loading...";
    window.clearTimeout(submitTime);
}

function StopSubmit() {
    document.getElementById('lnkStop').style.display = "none";
    document.getElementById('divLoadingMessage').innerHTML = "Stopping request...";
    if (navigator.appName == "Microsoft Internet Explorer") {
        window.document.execCommand('Stop');
    }
    else {
        window.stop();
    }

    window.location.reload(false);
    submitTime = window.setTimeout("HideSubmitLoading()", 1000);
    document.getElementById('divLoadingMessage').innerHTML = "Cancelling request...";
}

function HideSubmitLoading() {
    document.getElementById('divSubmitLoading').style.display = "none";
    window.clearTimeout(submitTime);
}

function ShowSubmitProgress(validationGroup) {
    var IsPageValid = Page_ClientValidate(validationGroup);

    //alert(IsPageValid);
    if (IsPageValid != null && IsPageValid == true) {
        //submitTime =  window.setTimeout("ShowSubmitLoading()", 2000);
    }
    else {
        //submitTime =  window.setTimeout("HideSubmitLoading()", 500);
        //alert("HideSubmitLoading");
    }
}

function ShowPageLoadingProgress() {
    pageTime = window.setTimeout("ShowPageLoading()", 1000);
    //return true;
}

function ShowPageLoading() {
    try {
        document.getElementById('divPageLoading').style.display = "";
        document.getElementById('lnkPageStop').style.display = "none";
        document.getElementById('divPageLoadingMessage').innerHTML = "Loading...";
        window.clearTimeout(pageTime);
        pageTime = window.setTimeout("ChangePageLoadingMessage()", 5000);
    }
    catch (ex) {
        //alert(ex.toString());
    }
}

function StopPageLoading() {
    document.getElementById('lnkPageStop').style.display = "none";
    document.getElementById('divPageLoadingMessage').innerHTML = "Stopping request...";
    if (navigator.appName == "Microsoft Internet Explorer") {
        window.document.execCommand('Stop');
    }
    else {
        window.stop();
    }

    //window.location.reload(false);
    pageTime = window.setTimeout("HidePageLoading()", 1000);
    document.getElementById('divPageLoadingMessage').innerHTML = "Cancelling request...";
}

function HidePageLoading() {
    document.getElementById('divPageLoading').style.display = "none";
    document.getElementById('divPageLoadingMessage').innerHTML = "Loading...";
    document.getElementById('lnkPageStop').style.display = "none";
    window.clearTimeout(pageTime);
}

function ChangePageLoadingMessage() {
    document.getElementById('divPageLoadingMessage').innerHTML = "Still loading...";
    window.clearTimeout(pageTime);
    pageTime = window.setTimeout("HidePageLoading()", 60000);
}
//END LOADING PROGRESS//
//################################//


//################################//
//VALIDATION EFFECT//
function ShowValidationEffect(ctrlId, ctrlValId) {
    //alert('Hello');
    if (typeof (Page_Validators) == "undefined") return;
    var valCtrl = document.getElementById(ctrlValId);
    var Ctrl = document.getElementById(ctrlId);
    ValidatorValidate(valCtrl);

    if (valCtrl.isvalid == false) {
        //alert('Not Valid');
        //Ctrl.className = 'validationError';
        AddRemoveCss(valCtrl, false);
    }
    else if (Ctrl.value.length == 0) {
        AddRemoveCss(valCtrl, false);
        //ValidatorValidate(valCtrl);
    }
    else if (Ctrl.value == "-1") {
        AddRemoveCss(valCtrl, false);
        //ValidatorValidate(valCtrl);
    }
    else {
        //alert('Is Valid');
        //Ctrl.className = 'noError';
        AddRemoveCss(valCtrl, true);
    }
}

function ShowValidationEffectMinusTwo(ctrlId, ctrlValId) {
    //alert('Hello');
    if (typeof (Page_Validators) == "undefined") return;
    var valCtrl = document.getElementById(ctrlValId);
    var Ctrl = document.getElementById(ctrlId);
    ValidatorValidate(valCtrl);

    if (valCtrl.isvalid == false) {
        //alert('Not Valid');
        //Ctrl.className = 'validationError';
        AddRemoveCss(valCtrl, false);
    }
    else if (Ctrl.value.length == 0) {
        AddRemoveCss(valCtrl, false);
        //ValidatorValidate(valCtrl);
    }
    else if (Ctrl.value == "-2") {
        AddRemoveCss(valCtrl, false);
        //ValidatorValidate(valCtrl);
    }
    else {
        //alert('Is Valid');
        //Ctrl.className = 'noError';
        AddRemoveCss(valCtrl, true);
    }
}


function ShowValidationEffectNoRequire(ctrlId, ctrlValId) {
    //alert('Hello');
    if (typeof (Page_Validators) == "undefined") return;
    var valCtrl = document.getElementById(ctrlValId);
    var Ctrl = document.getElementById(ctrlId);
    if (valCtrl.isvalid == false) {
        //alert('Not Valid');
        //Ctrl.className = 'validationError';
        AddRemoveCss(valCtrl, false);
    }
    else {
        //alert('Is Valid');
        //Ctrl.className = 'noError';
        AddRemoveCss(valCtrl, true);
    }
}

function ShowValidationEffectTwo(ctrlId, ctrlValIdOne, ctrlValIdTwo) {

    if (typeof (Page_Validators) == "undefined") return;
    var valCtrlOne = document.getElementById(ctrlValIdOne);
    var valCtrlTwo = document.getElementById(ctrlValIdTwo);
    var Ctrl = document.getElementById(ctrlId);
    //    alert('Hello');
    ValidatorValidate(valCtrlOne);
    ValidatorValidate(valCtrlTwo);
    //alert(valCtrlOne.isvalid);
    //alert(valCtrlTwo.isvalid);
    if (valCtrlOne.isvalid == false) {
        //alert('Not Valid One');
        //Ctrl.className = 'validationError';
        AddRemoveCss(valCtrlOne, false);
    }
    else if (valCtrlTwo.isvalid == false) {
        //alert('Not Valid Two');
        //Ctrl.className = 'validationError';
        AddRemoveCss(valCtrlTwo, false);
    }
    else if (Ctrl.value.length == 0) {
        AddRemoveCss(valCtrlOne, false);
        ValidatorValidate(valCtrlOne);
    }
    else {
        //alert('Is Valid');
        //Ctrl.className = 'noError';
        AddRemoveCss(valCtrlOne, true);
        AddRemoveCss(valCtrlTwo, true);
    }
}

function ShowValidationEffectThree(ctrlId, ctrlValIdOne, ctrlValIdTwo, ctrlValIdThree) {
    //alert('Hello');
    if (typeof (Page_Validators) == "undefined") return;
    var valCtrlOne = document.getElementById(ctrlValIdOne);
    var valCtrlTwo = document.getElementById(ctrlValIdTwo);
    var valCtrlThree = document.getElementById(ctrlValIdThree);
    var Ctrl = document.getElementById(ctrlId);
    //ValidatorValidate(valCtrlOne);
    //ValidatorValidate(valCtrlTwo);
    if (valCtrlOne.isvalid == false) {
        //alert('Not Valid One');
        AddRemoveCss(valCtrlOne, false);
        //Ctrl.className = 'validationError';
    }
    else if (valCtrlTwo.isvalid == false) {
        //alert('Not Valid Two');
        AddRemoveCss(valCtrlTwo, false);
        //Ctrl.className = 'validationError';
    }
    else if (valCtrlThree.isvalid == false) {
        //alert('Not Valid Three');
        AddRemoveCss(valCtrlThree, false);
        //Ctrl.className = 'validationError';
    }
    else if (Ctrl.value.length == 0) {
        AddRemoveCss(valCtrlOne, false);
    }
    else if (Ctrl.value == "-1") {
        AddRemoveCss(valCtrlOne, false);
    }
    else {
        //alert('Is Valid');
        AddRemoveCss(valCtrlOne, true);
        //Ctrl.className = 'noError';
    }
}

//function AddRemoveCss(valctrl,flag1)
//{
//    var el = document.getElementById(valctrl.controltovalidate);
//    if (el != null) {
//        if (valctrl.validationErrorCssClass || (valctrl.validationErrorCssClass = valctrl.getAttribute("validationErrorCssClass"))) {
//            var flag2 = el.className.indexOf(valctrl.validationErrorCssClass) != -1;
//            if (flag1 && flag2) {
//                el.className = el.className.replace(new RegExp("\\b" + valctrl.validationErrorCssClass + "\\b", "i"), "").replace(/^\s+|\s(?=\s+)|\s+$/m, "");
//            }
//            else if (!flag1 && !flag2) {
//                el.className += (el.className.length != 0 ? " " : "") + valctrl.validationErrorCssClass;
//            }
//        }
//    }
//}

function AddRemoveCss(valctrl, flag1) {
    var el = document.getElementById(valctrl.controltovalidate);
    //alert(el);
    if (el != null) {

        var flag2 = el.className.indexOf("validationError") != -1;
        if (flag1 && flag2) {
            //alert("1 and 2");
            el.className = el.className.replace(new RegExp("\\b" + "validationError" + "\\b", "i"), "").replace(/^\s+|\s(?=\s+)|\s+$/m, "");
        }
        else if (!flag1 && !flag2) {
            //alert("not both");
            el.className += (el.className.length != 0 ? " " : "") + "validationError";
        }

        /*if (valctrl.validationErrorCssClass || (valctrl.validationErrorCssClass = valctrl.getAttribute("validationErrorCssClass"))) {
        var flag2 = el.className.indexOf(valctrl.validationErrorCssClass) != -1;
        if (flag1 && flag2) {
        el.className = el.className.replace(new RegExp("\\b" + valctrl.validationErrorCssClass + "\\b", "i"), "").replace(/^\s+|\s(?=\s+)|\s+$/m, "");
        }
        else if (!flag1 && !flag2) {
        el.className += (el.className.length != 0 ? " " : "") + valctrl.validationErrorCssClass;
        }
        }*/
    }
}

function AddRemoveCssTwo(ctrl, flag1) {
    if (ctrl != null) {
        var flag2 = ctrl.className.indexOf("validationError") != -1;
        if (flag1 && flag2) {
            ctrl.className = ctrl.className.replace(new RegExp("\\b" + "validationError" + "\\b", "i"), "").replace(/^\s+|\s(?=\s+)|\s+$/m, "");
        }
        else if (!flag1 && !flag2) {
            ctrl.className += (ctrl.className.length != 0 ? " " : "") + "validationError";
        }
    }
}

function ShowValidationEffectDateCtrl(ddlDayId, ddlMonthId, ddlYearId, ctrlValId) {
    //alert('Hello');
    if (typeof (Page_Validators) == "undefined") return;
    var valCtrl = document.getElementById(ctrlValId);
    var ctrlDay = document.getElementById(ddlDayId);
    var ctrlMonth = document.getElementById(ddlMonthId);
    var ctrlYear = document.getElementById(ddlYearId);
    //ValidatorValidate(valCtrlOne);
    //ValidatorValidate(valCtrlTwo);
    if (valCtrl.isvalid == false) {
        //alert('Not Valid One');
        ctrlDay.className = 'validationError';
        ctrlMonth.className = 'validationError';
        ctrlYear.className = 'validationError';
    }
    else {
        //alert('Is Valid');
        ctrlDay.className = 'noError';
        ctrlMonth.className = 'noError';
        ctrlYear.className = 'noError';
    }
}

//function ShowValidationEffectOption(ctrlOptionOneId,ctrlOptionTwoId, txtCtrlId, ctrlValId)
//{
//    //alert('Hello');
//    if(typeof(Page_Validators) == "undefined") return;
//    var valCtrl = document.getElementById(ctrlValId);
//    var ctrlOptOne = document.getElementById(ctrlOptionOneId);
//    var ctrlOptTwo = document.getElementById(ctrlOptionTwoId);
//    var ctrlText = document.getElementById(txtCtrlId);
//    alert(ctrlText.value.length);
//    alert(valCtrl);
//    //ValidatorValidate(valCtrlOne);
//    //ValidatorValidate(valCtrlTwo);
//    //alert(valCtrl.isvalid);
//    if(valCtrl.isvalid == false)
//    {
//        //alert('Not Valid One');
//        //alert(ctrlOptOne);
//        AddRemoveCss(ctrlOptOne,false);
//        AddRemoveCss(ctrlOptTwo,false);
//        //ctrlOptOne.className = 'validationError';
//        //ctrlOptTwo.className = 'validationError';
//    }
//    else if(ctrlText.value.length == 0)
//    {
//        //AddRemoveCss(ctrlOptOne,false);
//        //AddRemoveCss(ctrlOptTwo,false);
//        alert("value zero");
//        ctrlOptOne.className = 'validationError';
//        ctrlOptTwo.className = 'validationError';
//        
//        ValidatorValidate(valCtrl);
//    }
//    else
//    {
//        //alert('Is Valid');
//        AddRemoveCss(ctrlOptOne,true);
//        AddRemoveCss(ctrlOptTwo,true);
//        //ctrlOptOne.className = 'noError';
//        //ctrlOptTwo.className = 'noError';
//    }
//}

function ShowValidationEffectOption(divCtrlYesId, divCtrlNoId, txtCtrlId, ctrlValId) {
    //alert('Hello');
    if (typeof (Page_Validators) == "undefined") return;
    var valCtrl = document.getElementById(ctrlValId);
    var ctrlYesDiv = document.getElementById(divCtrlYesId);
    var ctrlNoDiv = document.getElementById(divCtrlNoId);
    var ctrlText = document.getElementById(txtCtrlId);
    ValidatorValidate(valCtrl);
    if (valCtrl.isvalid == false) {
        AddRemoveCssTwo(ctrlYesDiv, false);
        AddRemoveCssTwo(ctrlNoDiv, false);
    }
    else if (ctrlText.value.length == 0) {
        AddRemoveCssTwo(ctrlYesDiv, false);
        AddRemoveCssTwo(ctrlNoDiv, false);
        ValidatorValidate(valCtrl);
    }
    else {
        AddRemoveCssTwo(ctrlYesDiv, true);
        AddRemoveCssTwo(ctrlNoDiv, true);
        ValidatorValidate(valCtrl);
    }

    //alert(ctrlText.value.length);
    //alert(valCtrl);
    //ValidatorValidate(valCtrlOne);
    //ValidatorValidate(valCtrlTwo);
    //alert(valCtrl.isvalid);
}



function ShowValidationEffectOptionThree(divCtrl1Id, divCtrl2Id, divCtrl3Id, txtCtrlId, ctrlValId) {
    //alert('Hello');
    if (typeof (Page_Validators) == "undefined") return;
    var valCtrl = document.getElementById(ctrlValId);
    var ctrl1Div = document.getElementById(divCtrl1Id);
    var ctrl2Div = document.getElementById(divCtrl2Id);
    var ctrl3Div = document.getElementById(divCtrl3Id);
    var ctrlText = document.getElementById(txtCtrlId);
    ValidatorValidate(valCtrl);
    if (valCtrl.isvalid == false) {
        AddRemoveCssTwo(ctrl1Div, false);
        AddRemoveCssTwo(ctrl2Div, false);
        AddRemoveCssTwo(ctrl3Div, false);
    }
    else if (ctrlText.value.length == 0) {
        AddRemoveCssTwo(ctrl1Div, false);
        AddRemoveCssTwo(ctrl2Div, false);
        AddRemoveCssTwo(ctrl3Div, false);
        ValidatorValidate(valCtrl);
    }
    else {
        AddRemoveCssTwo(ctrl1Div, true);
        AddRemoveCssTwo(ctrl2Div, true);
        AddRemoveCssTwo(ctrl3Div, true);
        ValidatorValidate(valCtrl);
    }
}


function ShowValidationEffectOptionFour(divCtrl1Id, divCtrl2Id, divCtrl3Id, divCtrl4Id, txtCtrlId, ctrlValId) {
    //alert('Hello');
    if (typeof (Page_Validators) == "undefined") return;
    var valCtrl = document.getElementById(ctrlValId);
    var ctrl1Div = document.getElementById(divCtrl1Id);
    var ctrl2Div = document.getElementById(divCtrl2Id);
    var ctrl3Div = document.getElementById(divCtrl3Id);
    var ctrl4Div = document.getElementById(divCtrl4Id);
    var ctrlText = document.getElementById(txtCtrlId);
    ValidatorValidate(valCtrl);
    if (valCtrl.isvalid == false) {
        AddRemoveCssTwo(ctrl1Div, false);
        AddRemoveCssTwo(ctrl2Div, false);
        AddRemoveCssTwo(ctrl3Div, false);
        AddRemoveCssTwo(ctrl4Div, false);
    }
    else if (ctrlText.value.length == 0) {
        AddRemoveCssTwo(ctrl1Div, false);
        AddRemoveCssTwo(ctrl2Div, false);
        AddRemoveCssTwo(ctrl3Div, false);
        AddRemoveCssTwo(ctrl4Div, false);
        ValidatorValidate(valCtrl);
    }
    else {
        AddRemoveCssTwo(ctrl1Div, true);
        AddRemoveCssTwo(ctrl2Div, true);
        AddRemoveCssTwo(ctrl3Div, true);
        AddRemoveCssTwo(ctrl4Div, true);
        ValidatorValidate(valCtrl);
    }
}

function ShowValidationEffectOptionFive(divCtrl1Id, divCtrl2Id, divCtrl3Id, divCtrl4Id, divCtrl5Id, txtCtrlId, ctrlValId) {
    //alert('Hello');
    if (typeof (Page_Validators) == "undefined") return;
    var valCtrl = document.getElementById(ctrlValId);
    var ctrl1Div = document.getElementById(divCtrl1Id);
    var ctrl2Div = document.getElementById(divCtrl2Id);
    var ctrl3Div = document.getElementById(divCtrl3Id);
    var ctrl4Div = document.getElementById(divCtrl4Id);
    var ctrl5Div = document.getElementById(divCtrl5Id);
    var ctrlText = document.getElementById(txtCtrlId);
    ValidatorValidate(valCtrl);
    if (valCtrl.isvalid == false) {
        AddRemoveCssTwo(ctrl1Div, false);
        AddRemoveCssTwo(ctrl2Div, false);
        AddRemoveCssTwo(ctrl3Div, false);
        AddRemoveCssTwo(ctrl4Div, false);
        AddRemoveCssTwo(ctrl5Div, false);
    }
    else if (ctrlText.value.length == 0) {
        AddRemoveCssTwo(ctrl1Div, false);
        AddRemoveCssTwo(ctrl2Div, false);
        AddRemoveCssTwo(ctrl3Div, false);
        AddRemoveCssTwo(ctrl4Div, false);
        AddRemoveCssTwo(ctrl5Div, false);
        ValidatorValidate(valCtrl);
    }
    else {
        AddRemoveCssTwo(ctrl1Div, true);
        AddRemoveCssTwo(ctrl2Div, true);
        AddRemoveCssTwo(ctrl3Div, true);
        AddRemoveCssTwo(ctrl4Div, true);
        AddRemoveCssTwo(ctrl5Div, true);
        ValidatorValidate(valCtrl);
    }
}
//END VALIDATION EFFECT//
//#####################################//


//#####################################//
//END VALIDATION ERROR//
var IsLoadValidationError;
function LoadValidationErrorCss() {

    if (IsLoadValidationError != null && IsLoadValidationError == true) return IsLoadValidationError;
    //Checking if ValidatorValidate exists
    //alert('Loaded');
    IsLoadValidationError = true;
    if (typeof (ValidatorValidate) != "undefined") {

        //Copy ValidatorValidate to BaseValidatorValidate
        BaseValidatorValidate = ValidatorValidate;
        //alert('validationerror 1');
        //Used to remeber the current activated validationGroup
        _lastValidationGroup = null;

        //Replacing ValidatorValidate
        ValidatorValidate = function(val, validationGroup, event) {
            //Calling original ValidatorValidate function saved in BaseValidatorValidate
            // alert('validationerror 2');

            BaseValidatorValidate(val, validationGroup, event);

            //Remembering the current validationGroup
            if (validationGroup != null) _lastValidationGroup = validationGroup;

            //Seting valid all the validations not in the current validationGroup
            if ((typeof (val.validationGroup) == "undefined" && _lastValidationGroup != "") || (typeof (val.validationGroup) != "undefined" && val.validationGroup != _lastValidationGroup)) val.isvalid = true;

            //***** To View Error Message *****//
            val.errormessage = val.id.toString() + " " + validationGroup;
            //***********************************
            //alert('validationerror 3');
            //If a validationErrorCssClass is defined ...
            if (val.className || val.className.indexOf("validationErrorControl") != -1) {
                //Checking if all validators on the same controltovalidate with the same validationGroup are valid
                var flag1 = val.isvalid;

                for (var num1 = 0; num1 < Page_Validators.length; num1++) {
                    var val2 = Page_Validators[num1];
                    if (val2.controltovalidate == val.controltovalidate && (validationGroup == null || typeof (val2.validationGroup) == "undefined" || val2.validationGroup == validationGroup)) flag1 &= val2.isvalid;
                }

                //Adding or removing validationErrorCssClass from controltovalidate
                if (typeof ($get) != "undefined") {
                    //Do it with ASP.NET ajax functions
                    Sys.UI.DomElement[flag1 ? 'removeCssClass' : 'addCssClass']($get(val.controltovalidate), "validationError");
                }
                else {
                    //Do it with standard javascript without ajax functions
                    var el = document.getElementById(val.controltovalidate);

                    if (el != null) {
                        var flag2 = el.className.indexOf("validationError") != -1;
                        if (flag1 && flag2) {
                            el.className = el.className.replace(new RegExp("\\b" + "validationError" + "\\b", "i"), "").replace(/^\s+|\s(?=\s+)|\s+$/m, "");
                        }
                        else if (!flag1 && !flag2) {
                            el.className += (el.className.length != 0 ? " " : "") + "validationError";
                        }
                    }
                }
            }

            //Refreshing ValidationSummary
            /*if (typeof (Page_ValidationSummaries) != "undefined" && _lastValidationGroup != null) {
            for (var num2 = 0; num2 < Page_ValidationSummaries.length; num2++) {
            var pageVal = Page_ValidationSummaries[num2];
            //If the ValidationSummary validationGroup is equal the last validationGroup updating it.
            if ((typeof (pageVal.validationGroup) == "undefined" && _lastValidationGroup == "") || (typeof (pageVal.validationGroup) != "undefined" && pageVal.validationGroup == _lastValidationGroup)) {
            setTimeout(function() { ValidationSummaryOnSubmit(_lastValidationGroup); }, 0);
            break;
            }
            }
            }*/
        }
        return IsLoadValidationError;
    }
}
////END VALIDATION ERROR//
//#####################################//

//###########BUTTON################################//
function ShowSubmitNormalMouseDown(aButton) {
    aButton.className = 'button_normal_submit_mousedown';
}

function ShowSubmitImageMouseDown(aButton) {
    aButton.className = 'button_submit_mousedown';
}

function ShowSubmitNormal(aButton) {
    aButton.className = 'button_submit';
}

function ShowSubmitImage(aButton) {
    aButton.className = 'button_normal_submit';
}

function RemoveAttribute(aButton, attributeName) {
    aButton.removeAttribute(attributeName);
}

function ShowNormalProcessing(aButton) {
    if (typeof (ValidatorValidate) != 'undefined') {
        if (Page_ClientValidate('none')) {
            RemoveAttribute(aButton, 'onmouseout'); RemoveAttribute(aButton, 'onmouseup'); aButton.className = 'button_normal_processing'; aButton.value = "Please wait...";
        }
    }
    else {
        RemoveAttribute(aButton, 'onmouseout'); RemoveAttribute(aButton, 'onmouseup'); aButton.className = 'button_normal_processing';
        aButton.value = "Please wait...";
    } return true;
}

function ShowImageProcessing(aButton) {
    if (typeof (ValidatorValidate) != 'undefined') {
        if (Page_ClientValidate('none')) {
            RemoveAttribute(aButton, 'onmouseout'); RemoveAttribute(aButton, 'onmouseup'); aButton.className = 'button_processing';
        }
    }
    else {
        RemoveAttribute(aButton, 'onmouseout'); RemoveAttribute(aButton, 'onmouseup'); aButton.className = 'button_processing';
    } return true;
}

function SetSumitNormalButtonAttribute(aSubmitButton) {
    if (typeof (aSubmitButton) != 'undefined') {
        if (aSubmitButton != null) {
            aSubmitButton.setAttribute("class", "button_normal_submit");
            aSubmitButton.setAttribute("onmouseout", "this.className = 'button_normal_submit';");
            aSubmitButton.setAttribute("onmouseup", "this.className = 'button_normal_submit';");
            aSubmitButton.setAttribute("onmousedown", "this.className = 'button_normal_submit_mousedown';");
        }
    }
}

function SetSumitImageButtonAttribute(aSubmitButton) {
    aSubmitButton.setAttribute("class", "button_submit");
    aSubmitButton.setAttribute("onmouseout", "this.className = 'button_submit';");
    aSubmitButton.setAttribute("onmouseup", "this.className = 'button_submit';");
    aSubmitButton.setAttribute("onmousedown", "this.className = 'button_submit_mousedown';");
}
//##########END BUTTON################
//]]>